$(document).ready(function() {




}); 

function sortGallerya(){


    //  alert($(".orderby span.select2-chosen").text());   //  alert($(".sort-by ul li.active").text());
    /*. . . Sort By Name  . . . */
      if( $(".sort-by ul li.active").text() == "Name"){
          
            if( $(".orderby span.select2-chosen").text() == "Ascending" ){
                             
                      //get all name put array
                      var arrNames = [] ; 
                      $("ul li.item._display").each(function(){
                          arrNames.push( $(this).find(".product-name a").text().trim() );
                      });  
                      console.log("@sorting functions");
                      
                      // sort arrNames  order by ascending 
                      arrNames.sort(); // sorted na 
                      var temp_items = [];
                      // match order to 
                      $(arrNames).each(function( index , value ){ 
                        $("ul li.item").each(function(ik,vl){
                            if( $(vl).find(".product-name a").text().trim() == value ){
                                temp_items.push(this);
                            }
                            else if( $(vl).hasClass("_hide") ){
                                temp_items.push(this);
                            }
                        });
                      }); 
                      console.log(". . . . this is  sorted . . . . ");
                      console.log(temp_items); 
                      $("ul.gallery-products").empty();   
                      $("ul.gallery-products").html(temp_items);          

            }else{
                /* . . . Order by Descending Sort by Name. . . . */
                   var arrNames = [] ; 
                      $("ul li.item._display").each(function(){
                          arrNames.push( $(this).find(".product-name a").text().trim() );
                      });  
                      console.log("@sorting functions");
                      
                      // sort arrNames  order by ascending 
                      arrNames.sort();  arrNames.reverse();// sorted na 
                      var temp_items = [];
                      // match order to 
                      $(arrNames).each(function( index , value ){ 
                        $("ul li.item").each(function(ik,vl){
                            if( $(vl).find(".product-name a").text().trim() == value ){
                                temp_items.push(this);
                            }
                            else if( $(vl).hasClass("_hide") ){
                                temp_items.push(this);
                            }
                        });
                      }); 
                      console.log(". . . . this is  sorted . . . . ");
                      console.log(temp_items); 
                      $("ul.gallery-products").empty();   
                      $("ul.gallery-products").html(temp_items);  
            }




      } /*. . . Sort By Price . . . */
      else if( $(".sort-by ul li.active").text() == "Price"){

           if( $(".orderby span.select2-chosen").text() == "Ascending" ){



            }else{
                /* . . . Order by Descending Sort by Price. . . . */



            }


      }

        
}

